home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_createextraobject.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  65 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. struct Gadget *
  17. LTP_CreateExtraObject(LayoutHandle *handle,ObjectNode *parentNode,struct Gadget *parentGadget,struct NewGadget *ng,LONG imageType,LONG incAmount)
  18. {
  19.     ObjectNode        *node;
  20.     struct Gadget    *gadget;
  21.  
  22.     if(node = LTP_CreateObjectNode(handle,incAmount ? INCREMENTER_KIND : PICKER_KIND,parentGadget->GadgetID,NULL))
  23.     {
  24.         ng->ng_LeftEdge        = ng->ng_LeftEdge + ng->ng_Width;
  25.         ng->ng_Width        = incAmount ? (4 + handle->GlyphWidth + 4) : LTP_GetPickerSize(handle);
  26.         ng->ng_GadgetText    = "";
  27.         ng->ng_UserData        = node;
  28.         ng->ng_Flags        = NULL;
  29.  
  30.         if(incAmount)
  31.             node->Special.Incrementer.Amount = incAmount;
  32.  
  33.         node->Special.Incrementer.Image = NewObject(LTP_ImageClass,NULL,
  34.             IIA_ImageType,    imageType,
  35.             IA_Width,        ng->ng_Width,
  36.             IA_Height,        ng->ng_Height,
  37.         TAG_DONE);
  38.  
  39.         if(node->Special.Incrementer.Image)
  40.         {
  41.             if(gadget = CreateGadgetA(GENERIC_KIND,handle->Previous,ng,NULL))
  42.             {
  43.                 gadget->GadgetType        |= GTYP_BOOLGADGET;
  44.                 gadget->Flags            |= GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
  45.                 gadget->Activation        |= GACT_IMMEDIATE | GACT_RELVERIFY;
  46.                 gadget->GadgetRender     = node->Special.Incrementer.Image;
  47.                 gadget->SelectRender     = node->Special.Incrementer.Image;
  48.  
  49.                 if(parentNode->Disabled)
  50.                     gadget->Flags |= GFLG_DISABLED;
  51.  
  52.                 node->Host = gadget;
  53.  
  54.                 node->Special.Incrementer.Parent = parentGadget;
  55.  
  56.                 return(gadget);
  57.             }
  58.             else
  59.                 LTP_DeleteObjectNode(handle,node);
  60.         }
  61.     }
  62.  
  63.     return(NULL);
  64. }
  65.